//
//  PersonMessageTableViewCell.swift
//  ABSallRec
//
//  Created by 我演示 on 2019/11/18.
//  Copyright © 2019 Jerry-Fu. All rights reserved.
//

import UIKit
import SnapKit

class PersonMessageTableViewCell: UITableViewCell {
    
    weak  var   loginBtn : UIButton?
    
    //背景
    lazy var backGroundImage: UIImageView = {
        let backImageView = UIImageView.init(image: UIImage.init(named: "mine_header_background"))
        return backImageView
    }()
    
    /// 全部使用懒加载数据
    lazy var  iconImage: UIImageView = {
        let iconImge = UIImageView(image: UIImage.init(named: "mine_head_icon"))
        return iconImge
    }()
        
    /// 领取大奖的label
    
    lazy var getBigPrize: UILabel = {
        let getBigPrizeLabel = UILabel.init("登录立即领取新人大礼包", textFont: 10, textAlignment: .left)
        getBigPrizeLabel.textColor = UIColor.initWithHex(hexString: "#F0C7A8")
        return getBigPrizeLabel
    }()
    
    
    
    @objc   static  func cellWithTableView (_ tableView: UITableView) -> PersonMessageTableViewCell {
        let string = "string"
       var  cell = tableView.dequeueReusableCell(withIdentifier: string)
        if (cell == nil) {
            cell = PersonMessageTableViewCell(style: .default, reuseIdentifier: string)
        }
        return cell  as! PersonMessageTableViewCell
        
    }
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: .default, reuseIdentifier: reuseIdentifier)
   
        makeUpUI()
        makeUpSubviews()
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        self.selectionStyle = .none;
    }

}


extension PersonMessageTableViewCell {
    fileprivate func makeUpUI (){
        self.contentView.addSubview(backGroundImage)
        self.contentView.addSubview(iconImage)
        
        
        let loginBtn = UIButton.init(type: .custom)
        loginBtn.backgroundColor = UIColor.red
        loginBtn.setTitle("登录", for: .normal)
        self.contentView.addSubview(loginBtn)
        self.loginBtn = loginBtn
        
        self.contentView.addSubview(self.getBigPrize);
//        self.getBigPrize
        
    }
    
    fileprivate func makeUpSubviews() {
        backGroundImage.snp.makeConstraints { (make) in
            make.left.top.right.bottom.equalTo(self).offset(0)
        }
        
        iconImage.snp.makeConstraints { (make) in
            make.left.equalTo(self.contentView.snp_left).offset(23)
            make.top.equalTo(self.contentView).offset(0)
            make.width.equalTo(60)
            make.height.equalTo(60)
        }
        loginBtn?.snp.makeConstraints({ (make) in
            make.left.equalTo(iconImage.snp_right).offset(12)
            make.top.equalTo(iconImage.snp_top).offset(7)
            make.right.equalTo(self.contentView.snp_right).offset(0)
            make.height.equalTo(27)
        })
        
    }
    
}
